package com.ls.x.broadcastreceiver;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.ls.x.R;
import com.ls.x.activity.ContentShowActivity;

public class AlarmBroadCastReceiver extends BroadcastReceiver {

	private static final int REMIND_ID = 1;
	
	@Override
	public void onReceive(Context context, Intent intent) {
		Log.d("Sunway", "AlarmBroadCastReceiver receive a intent");
		
		NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
		
		String uuid=intent.getStringExtra("uudi");
		String tital=intent.getStringExtra("tital");
		String summary=intent.getStringExtra("summary");
		
		int icon = R.drawable.ic_launcher;
		long when = System.currentTimeMillis();

		Intent intentForRemind = new Intent(context, ContentShowActivity.class);
		intentForRemind.putExtra("uuid", uuid);
		
		PendingIntent pendingIntent=PendingIntent.getActivity(context, 0, intentForRemind, PendingIntent.FLAG_ONE_SHOT);
		
		Notification notification = new Notification(icon, tital, when);
		
		notification.setLatestEventInfo(context, tital, summary, pendingIntent);
		
		notificationManager.notify(REMIND_ID, notification);
		
	}
}
